package com.woniuxy.litener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
@Slf4j
public class EmailListener {
    @Autowired
    StringRedisTemplate stringRedisTemplate;
    @Autowired
    JavaMailSender mailSender;
    @RabbitListener(queues = "MyEmail.queue")
    public void sendEmail(HashMap<String,String> map){
        //1.获取消息队列，并封装
        SimpleMailMessage message = new SimpleMailMessage();
        message.setSubject(map.get("subject"));
        message.setText(map.get("text"));
        message.setFrom(map.get("from"));
        message.setTo(map.get("to"));

        //2.发送邮件
//        mailSender.send(message);
    }
}
